import requests
import re


# pip install 模块名 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
# pip install requests -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

# 升级pip:
# python -m pip install --upgrade pip

def get_html():
    url = "http://www.weather.com.cn/weather1d/101210101.shtml"
    resp = requests.get(url)
    resp.encoding = 'utf-8'
    return resp.text


def parse_html(html):
    city = re.findall('<span class="name">([\u4e00-\u9fa5]*)</span>', html)
    weather = re.findall('<span class="weather">([\u4e00-\u9fa5]*)</span>', html)
    wd = re.findall('<span class="wd">(.*)</span>', html)
    zs = re.findall('<span class="zs">([\u4e00-\u9fa5]*)</span>', html)

    lst = []
    for a, b, c, d in zip(city, weather, wd, zs):
        lst.append([a, b, c, d])
    return lst
